package com.signway.utils.threadPool;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2011-2018, by your Signway, All rights reserved.
 * -----------------------------------------------------------------
 *
 * ProjectName: Droid
 *
 * Author: Administrator
 *
 * Email: xing.zhu@Signway.cn
 *
 * Description: 线程池
 *
 * -----------------------------------------------------------------
 * 2018/8/20 0020 : Create ThreadPoolProxyFactory.java 
 * -----------------------------------------------------------------
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolProxyFactoryUtils {
    static ThreadPoolProxyUtils mNormalThreadPoolProxy;
    static ThreadPoolProxyUtils mDownLoadThreadPoolProxy;
    static ExecutorService mSingleThreadExecutor;


    /**
     * 得到队列线程池代理对象mSingleThreadExecutor
     */
    public static ExecutorService getSingleThreadExecutor() {
        if (mSingleThreadExecutor == null) {
            synchronized (ThreadPoolProxyFactoryUtils.class) {
                if (mSingleThreadExecutor == null) {
                    mSingleThreadExecutor = Executors.newSingleThreadExecutor();
                }
            }
        }
        return mSingleThreadExecutor;
    }


    /**
     * 得到普通线程池代理对象mNormalThreadPoolProxy
     */
    public static ThreadPoolProxyUtils getNormalThreadPoolProxy() {
        if (mNormalThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactoryUtils.class) {
                if (mNormalThreadPoolProxy == null) {
                    mNormalThreadPoolProxy = new ThreadPoolProxyUtils(2, 5);
                }
            }
        }
        return mNormalThreadPoolProxy;
    }


    /**
     * 得到下载线程池代理对象mDownLoadThreadPoolProxy
     */
    public static ThreadPoolProxyUtils getDownLoadThreadPoolProxy() {
        if (mDownLoadThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactoryUtils.class) {
                if (mDownLoadThreadPoolProxy == null) {
                    mDownLoadThreadPoolProxy = new ThreadPoolProxyUtils(1, 3);
                }
            }
        }
        return mDownLoadThreadPoolProxy;
    }


}

